package com.example.spring5.IOC.注解;

import com.example.spring5.bean.UserDao;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

//可以代替很多xml的配置
@Configuration//(proxyBeanMethods = false)//这是一个配置类 == 配置文件告诉spring boot这是一个配置类 主要
@ComponentScan({"com.example.spring5.IOC.注解","com.example.spring5.bean"})
//@SpringBootApplication(scanBasePackages = "com.example.spring5.IOC")
public class 配置类 {//完全注解开的发

    @Test
    public void 基于注解的扫描(){
//        以前
//        ApplicationContext a = new ClassPathXmlApplicationContext("IOC2.xml");

//        现在  但是 spring Boot最好
        ApplicationContext context =
                new AnnotationConfigApplicationContext(配置类.class);
        基于注解的Bean mybean = context.getBean("qqqqq", 基于注解的Bean.class);//工厂 bean
        mybean.工厂Bean();

    }


}
